package com.test.daily.leetcode.y2021.m10.day1007;

/**
 * countSegments
 *
 * https://leetcode-cn.com/problems/number-of-segments-in-a-string/
 *
 * @author Tom on 2021/10/7
 */
public class Code02_CountSegments {
    public static void main(String[] args) {
        String s = "     ";
        System.out.println(countSegments(s));
    }
    public static int countSegments(String s) {
        int count = 0;
     for(int i = 0; i < s.length(); i++){
         if( (i== 0 || s.charAt(i-1) == ' ') && s.charAt(i) != ' '){
             count++;
         }
     }
     return count;
    }
}
